#include <thread>
#include "JZCoFile.h"

JZCoFile::JZCoFile(QFile* file)
{
	m_file = file;
}

QByteArray JZCoFile::readAll()
{
	QByteArray buffer;
	jzco_waitThread([this,&buffer] {
		buffer = this->m_file->readAll();
	});
	return buffer;
}

qint64 JZCoFile::write(const QByteArray& buffer)
{
	jzco_waitThread([this, &buffer] {
		this->m_file->write(buffer);
	});
	return buffer.size();
}